package com.example.lanqiaodemo1.TestFour;

import java.util.Date;
//银行账户类
public class Account {
    private String id,name;
    private double balance;//账户余额
    private Date datetime;//开户时间

    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public double getBalance() { return balance; }
    public void setBalance(double balance) { this.balance = balance; }
    public Date getDatetime() { return datetime; }
    public void setDatetime(Date datetime) { this.datetime = datetime; }
    public Account(String id,String name,double balance){
        this.id=id;
        this.balance=balance;
        this.name=name;
        this.datetime=new Date();
    }
    public Account(){}
    //存钱
    public void deposite(double money){
        this.balance=this.balance+money;
    }
    //取钱
    public void withdraw(double money){
        if (this.balance<money){
            System.out.println("您的余额不足，不能取钱");
            return;
        }
        this.balance=this.balance-money;
    }
    //转账
    public void changeMoney(Account other,double money){
        if (this.balance<money){
            System.out.println("您的余额不足，不能取钱");
        }
        this.balance=this.balance-money;
        other.balance=other.balance+money;
    }
    //显示余额
    public void print(){
        System.out.println("账号： "+id+" 户名： "+name+" 余额： "+balance);
    }

}
